package cn.gotom.core.pojos;

import java.io.Serializable;
import javax.persistence.*;

import java.util.Set;

/**
 * 
 * 角色权限信息表
 * 
 * @author peixere@qq.com
 * 
 * @version 2012-12-03
 * 
 */
@Entity
@Table(name = "core_role")
public class Role extends BaseEntity implements Serializable
{
	private static final long serialVersionUID = 1L;

	@Column(nullable = false, length = 100)
	private String name;

	@Column(nullable = false)
	private int sort;

	// bi-directional many-to-many association to Right
	@ManyToMany
	@JoinTable(name = "core_role_right", joinColumns = { @JoinColumn(name = "role_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "right_id", nullable = false) })
	private Set<Right> rights;

	// bi-directional many-to-many association to User
	//@ManyToMany(mappedBy = "roles")
	@ManyToMany
	@JoinTable(name = "core_user_role", joinColumns = { @JoinColumn(name = "role_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_id", nullable = false) })
	private Set<User> users;

	public Role()
	{
	}

	public String getName()
	{
		return this.name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public int getSort()
	{
		return this.sort;
	}

	public void setSort(int sort)
	{
		this.sort = sort;
	}

	public Set<Right> getRights()
	{
		return this.rights;
	}

	public void setRights(Set<Right> rights)
	{
		this.rights = rights;
	}

	public Set<User> getUsers()
	{
		return this.users;
	}

	public void setUsers(Set<User> users)
	{
		this.users = users;
	}

}